import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import monacoEditorPlugin from 'vite-plugin-monaco-editor'
// import sass from 'sass'
import { compileString } from 'sass'

export default defineConfig({
	plugins: [
		vue(),
		monacoEditorPlugin({
			languageWorkers: ['editorWorkerService', 'typescript', 'json', 'html']
		})
	],
	resolve: {
		alias: {
			'@': path.join(__dirname, 'src'),
		},
	},
	// 全局配置  样式变量
	css: {
		preprocessorOptions: {
			scss: {
				additionalData: '@use "@/styles/variables.scss" as *;',
				// 解决sass报错问题
				api: 'modern-compiler' // or "modern"
			},
		},
	},
	server: {
		proxy: {
			'/serverGovernance': {
				timeout: 30000,
				target: 'http://10.64.15.85:8480',
				changeOrigin: true,
				rewrite: path => path.replace(/^\/serverGovernance/, ''),
			},
			'/admin-api': {
				timeout: 30000,
				target: 'http://www.baidu.com:8480',
				changeOrigin: true,
				rewrite: path => path.replace(/^\/admin-api/, ''),
			},
			'/api': {
				timeout: 30000,
				target: 'http://localhost:3001',
				changeOrigin: true,
				// rewrite: path => path.replace(/^\/serverGovernance/, ''),
			},
		},
	},
})
